package com.hxkcloud.patient.permissions;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

import com.hxkcloud.patient.aerotel.view.ConfirmDialog;


/**
 * Created by songyuequan on 2016/5/6.
 */
public class PermissionDialogUtil {


    public static final int PERMISSIONS_CODE_CAMERA = 201;

    public static void show(final Context context, String content){
        new ConfirmDialog(context, "权限管理",content,
                new ConfirmDialog.OnConfirmListener() {
                    @Override
                    public void onOk(ConfirmDialog dialog) {
                        dialog.dismiss();
                        Intent intent;
                        String pkgName = context.getPackageName();
                        if (android.os.Build.VERSION.SDK_INT >= 9) {
        /* on 2.3 and newer, use APPLICATION_DETAILS_SETTINGS with proper URI */
                            Uri packageURI = Uri.parse("package:" + pkgName);
                            intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", packageURI);
                            context.startActivity(intent);
                        }  else  {
        /* on older Androids, use trick to show app details */
                            intent = new Intent(Intent.ACTION_VIEW);
                            intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
                            intent.putExtra("com.android.settings.ApplicationPkgName", pkgName);
                            intent.putExtra("pkg", pkgName);
                            context.startActivity(intent);
                        }
                    }
                }).show();
    }
}
